/*
 * @Author: Leander 
 * @Date: 2019-03-03 16:49:28 
 * @Last Modified by: Leander
 * @Last Modified time: 2019-03-19 10:34:46
 */

import Vue from 'vue'
import Router from 'vue-router'
import store from '@/store'
import { routes } from './path'
import { localStorage } from '@/common/storage'

Vue.use(Router)

const router = new Router({
  routes,
  mode: 'hash'
})

//路由开始之前的操作
router.beforeEach((to, from, next) => {
  // 获取登录信息
  let progress = localStorage.get('progress');
  if (progress == 1) {
    next()
} else {
  localStorage.set('progress', 1);
  next({
    name: 'layout'
  })
}
// next()
})

//路由完成之后的操作
router.afterEach(route => {
  window.scrollTo(0, 0)
})

export default router
